<section class="section {page->class}">
	<h2 class="hide">{page->title}</h2>

	<script>
		$(function() {
			$("#{module}_add").validate({
				submitHandler : function(form) {
					// ajax로 등록후 list 페이지 새로 고침
					$.ajax({
						 url : form.action
						,data : $(form).serialize()
						,success:function(data){
							if(data.code == mesg.success) {
								if(data.menu_refresh_url) {
									$("aside#left menu").load(data.menu_refresh_url);
								}
								
								sagapo.section_refresh(data.return_url);
							} else {
								alert(data.msg);
							}
							
							return false;
						}
					});
				}
			});
			
			$("#{module}_overlap").click(function() {
				ids = $("#{module}_id");
				
				if(ids.valid()) {
					url = "{CFG->PATH->WWW}/{CFG->PATH->ADMIN}/{module}/getID/"+ids.val();
					$.ajax({url:url, success:function(data){
						if(mesg.success == data.code) {
							if(confirm(data.msg)) {
								$("#{module}_id2").val(ids.val());
							} else {
								ids.val("").focus();	
							}
						} else {
							alert(data.msg);
							ids.val("").focus();
						}
					}});
				} else {
					ids.focus();
				}
				return false;
			});
			
			
			// 메뉴 등록 checkbox 선택시
			$("#{module}_menu").click(function() {
				if($(this).is(":checked")) {
					$(".menu_icon").removeClass("hide");
				} else {
					$(".menu_icon").addClass("hide");
				}
			});
			
			
			// 반드시 id값으로 설정해줘야됨.
			// class로 하면 dialog가 제대로 열리지 않음.
			$("#menu_iconset").dialog({
				resizable	: false,
				modal		: true,
				width		: 500,
				minWidth	: 500,
				height		: 500,
				autoOpen	: false,
				title		: '아이콘 선택'
				
			});
			
			// 메뉴 아이콘 선택 창 표시
			$(".menu_icon button.menu_icon_select").click(function() {
				$("#menu_iconset").dialog('open');	
				
				return false;
			});
			
			
			// 아이콘 선택시..
			$("#menu_iconset .iconset .icon").click(function() {
				
				$(".menu_icon .select_icon").html($(this).clone());
				
				$("#{module}_icon").val($(this).attr("alt"));
				$("#menu_iconset").dialog('close');
				return false;
			});
		});
	</script>
	<form name="{module}_add" id="{module}_add" method="post" action="{action}/doAdd">
		<table class="table">
			<caption>
				{page->title}
			</caption>
			<colgroup>
				<col class="add" />
				<col />
			</colgroup>
			<tbody>
				<tr>
					<th scope="row" class="txt_right br"><label for="{module}_id">게시판 아이디</label></th>
					<td>
						<input type="text" name="{module}_id" id="{module}_id" class="required" placeholder="게시판 아이디" />
						<input type="hidden" name="{module}_id2" id="{module}_id2" placeholder="게시판 중복확인 체크" class="required" />
						<button type="button" class="accept" id="{module}_overlap">중복확인</button>
					</td>
				</tr>
				<tr>
					<th scope="row" class="txt_right br"><label for="{module}_name">게시판 명</label></th>
					<td><input type="text" name="{module}_name" id="{module}_name" class="width_90 required" placeholder="게시판 명" /></td>
				</tr>
				<tr class="odd">
					<th scope="row" class="txt_right br"><label for="{module}_skin">스킨</label></th>
					<td>
						<select name="{module}_skin">
							{@ skin}
							<option value="{.value_}">{.value_}</option>
							{/}
						</select>
					</td>
				</tr>
				<tr>
					<th scope="row" class="txt_right br"><label for="{module}_menu">메뉴등록</label></th>
					<td>
						<input type="checkbox" name="{module}_menu" id="{module}_menu" value="1" />
						<label for="{module}_menu">메뉴등록</label>
					</td>
				</tr>
				<tr class="menu_icon hide">
					<th scope="row" class="txt_right br">아이콘 선택</th>
					<td>
						<div class="select_icon"></div>
						<button type="button" class="menu_icon_select">아이콘 선택</button>
						<input type="hidden" name="{module}_icon" id="{module}_icon" />
					</td>
				</tr>
				<tr>
					<th scope="row" class="txt_right br"><label for="{module}_category_on">카테고리</label></th>
					<td>
						<input type="radio" name="{module}_category" id="{module}_category_on" value="1" checked="checked" />
						<label for="{module}_category_on">사용</label>
						&nbsp;&nbsp;
						<input type="radio" name="{module}_category" id="{module}_category_off" value="0" />
						<label for="{module}_category_off">미사용</label>
					</td>
				</tr>
				<tr>
					<th scope="row" class="txt_right br"><label for="{module}_footlist_on">하단리스트</label></th>
					<td>
						<input type="radio" name="{module}_footlist" id="{module}_footlist_on" value="1" checked="checked" />
						<label for="{module}_footlist_on">사용</label>
						&nbsp;&nbsp;
						<input type="radio" name="{module}_footlist" id="{module}_footlist_off" value="0" />
						<label for="{module}_footlist_off">미사용</label>
					</td>
				</tr>
				<tr>
					<th scope="row" class="txt_right br"><label for="{module}_newicontime">새글강조시간</label></th>
					<td>
						<input type="number" name="{module}_newicontime" id="{module}_newicontime" value="24" class="width_30px required"  max="168" min="1" />
						시간 단위로 입력해주세요.
					</td>
				</tr>
				<tr>
					<th scope="row" class="txt_right br"><label for="{module}_attach_on">첨부파일</label></th>
					<td>
						<input type="radio" name="{module}_attach" id="{module}_attach_on" value="1" checked="checked" />
						<label for="{module}_attach_on">사용</label>
						&nbsp;&nbsp;
						<input type="radio" name="{module}_attach" id="{module}_attach_off" value="0" />
						<label for="{module}_attach_off">미사용</label>
					</td>
				</tr>
				<tr>
					<th scope="row" class="txt_right br"><label for="{module}_listing">리스트 갯수</label></th>
					<td>
						<input type="number" name="{module}_listing" id="{module}_listing" value="15" class="width_30px required" max="30" min="5" />
					</td>
				</tr>
				<tr>
					<th scope="row" class="txt_right br"><label for="{module}_paging">페이징 갯수</label></th>
					<td>
						<input type="number" name="{module}_paging" id="{module}_paging" value="10" class="width_30px required" max="25" min="5" />
					</td>
				</tr>
				<tr>
					<th scope="row" class="txt_right br"><label for="{module}_thumb_width">썸네일 가로</label></th>
					<td>
						<input type="number" name="{module}_thumb_width" id="{module}_thumb_width" value="450" class="width_50px required"  max="700" /> px
					</td>
				</tr>
				<tr>
					<th scope="row" class="txt_right br"><label for="{module}_thumb_height">썸네일 세로</label></th>
					<td>
						<input type="number" name="{module}_thumb_height" id="{module}_thumb_height" value="300" class="width_50px required"  max="700" /> px
					</td>
				</tr>
			</tbody>
		</table>
		<div class="button_area">
			<button type="submit">전송</button>
		</div>
		
		<div id="menu_iconset">
			<ul class="iconset">
				{@ iconset}
				<li>
					<img src="{CFG->PATH->IMAGE}/iconset/{.value_->name}" alt="{.value_->name}" title="{.value_->name}" class="icon" />
				</li>
				{/}
			</ul>
		</div>
	</form>
</section>